﻿using System;

namespace Exam
{
    class Program 
    {
        static void Main() 
        {
            Healthy healthy = new Healthy();

            bool sex; 
            float height = 0;
            float weight = 0;

            while (1 > 0)
            {
                Console.WriteLine("请输入性别(男/女)");
                string Sex = Console.ReadLine();
                if (Sex == "男")
                {
                    sex = true;
                    break;
                }
                else if (Sex == "女")
                {
                    sex = false;
                    break;
                }
                else
                {
                    Console.WriteLine("请输入正确的值");
                }
            }
            while (1 > 0)
            {
                Console.WriteLine("请输入身高(cm)");
                string Height = Console.ReadLine();
                float.TryParse(Height, out height);
                if (height == 0 || height < 20)
                {
                    Console.WriteLine("请输入正确的数值");
                }
                else 
                {
                    break;
                }
            }

            while (1 > 0)
            {
                Console.WriteLine("请输入体重(kg)");
                string Weight = Console.ReadLine();
                float.TryParse(Weight, out weight);
                if (weight == 0 || height < 20)
                {
                    Console.WriteLine("请输入正确的数值");
                }
                else 
                {
                    break;
                }
            }
            Console.WriteLine(healthy.isHealthy(sex, height, weight));
            Console.ReadLine();
        }
    }
    class Healthy
    {
        public string isHealthy(bool sex,float height,float weight) 
        {
            float maleFlagWeight = ((height - 80) * 0.7f);//男标体
            float feMaleFlagWeight = ((height - 70) * 0.6f);//女标体

            if (sex == true)
            {
                if ((weight - maleFlagWeight) / maleFlagWeight > 0)
                {
                    if ((weight - maleFlagWeight) / maleFlagWeight > 0.2f)
                    {
                        return "肥胖,该减肥了";
                    }
                    else if ((weight - maleFlagWeight) / maleFlagWeight > 0.1f)
                    {
                        return "体重过重,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else if ((weight - maleFlagWeight) / maleFlagWeight < 0)
                {
                    if (MathF.Abs((weight - maleFlagWeight) / maleFlagWeight) > 0.2f)
                    {
                        return "体重不足,多吃东西";
                    }
                    else if (MathF.Abs((weight - maleFlagWeight)) / maleFlagWeight > 0.1f)
                    {
                        return "体重过轻,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else 
                {
                    return "体重正常";
                }


            }
            else if (sex == false)
            {
                if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0)
                {
                    if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0.2f)
                    {
                        return "肥胖,该减肥了";
                    }
                    else if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0.1f)
                    {
                        return "体重过重,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else if ((weight - feMaleFlagWeight) / feMaleFlagWeight < 0)
                {
                    if (MathF.Abs((weight - feMaleFlagWeight) / feMaleFlagWeight) > 0.2f)
                    {
                        return "体重不足,多吃东西";
                    }
                    else if (MathF.Abs((weight - feMaleFlagWeight)) / feMaleFlagWeight > 0.1f)
                    {
                        return "体重过轻,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else
                {
                    return "体重正常";
                }
            }
            else 
            {
                return "???人妖???";
            }
        }
    }
}
